﻿namespace ExcelAutomator.Validation
{
	public abstract class BaseValidator : IValidationResult
	{
		public BaseValidator()
		{
			IsValid = true;
		}
		
		public BaseValidator(string context) : this()
		{
			Context = context;
		}

		public void SetFailure(string message, string context)
		{
			Message = message;
			Context = context;
			IsValid = false;
		}

		public bool IsValid { get; protected set; }

		public string Message { get; protected set; }

		public string Context { get; protected set; }

		public override string ToString()
		{
			return string.Format("{0} ({1}): {2}", this.GetType().Name, Context, Message, IsValid == true ? "IsValid" : "IsNotValid");
		}
	}
}